/* GUI CONVERTED from ececrp.p (converter v1.76) Thu Nov 21 03:06:02 2002 */
/* ececrp.p - --- ECN REPORT                                                  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.10.1.10 $                                                           */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 7.4      LAST EDIT: 09/29/93      MODIFIED BY: QZL *H013*        */
/* REVISION: 7.4      LAST EDIT: 08/25/94      MODIFIED BY: QZL *H488*        */
/* REVISION: 7.4      LAST EDIT: 03/08/95      MODIFIED BY: QZL *H0BX*        */
/* REVISION: 7.4      LAST EDIT: 04/10/95      MODIFIED BY: jpm *H0CH*        */
/* REVISION: 7.4      LAST EDIT: 04/20/95      MODIFIED BY: QZL *H0D4*        */
/* REVISION: 8.5      LAST EDIT: 07/19/96      MODIFIED BY: RVW *J0TY*        */
/* REVISION: 8.5      LAST EDIT: 10/04/96 MODIFIED BY: *J15L* Russ Witt       */
/* REVISION: 8.5      LAST EDIT: 11/05/96 MODIFIED BY: *J17Q* Murli Shastri   */
/* REVISION: 8.6      LAST EDIT: 12/10/96       MODIFIED BY: Joe Gawel *K00C* */
/* REVISION: 8.6      LAST EDIT: 04/01/97       MODIFIED BY: Joe Gawel *K08X* */
/* REVISION: 8.6      LAST EDIT: 10/20/97       MODIFIED BY: mur       *K136* */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 11/05/98   BY: *K1Y1* Felcy D'Souza      */
/* REVISION: 9.0      LAST MODIFIED: 04/08/99   BY: *J3D6* Mugdha Tambe       */
/* REVISION: 9.0      LAST MODIFIED: 04/26/99   BY: *J3DF* Jean Miller        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 07/11/00   BY: *N0FJ* Mudit Mehta        */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00   BY: *N0KW* Jacolyn Neder      */
/* $Revision: 1.10.1.10 $    BY: Amit Chaturvedi       DATE: 11/20/02  ECO: *N1TM*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

define new shared variable ecmnbr like ecm_nbr.
define variable ecnbr_fr          like ecm_nbr      no-undo.
define variable ecid_fr           like wo_lot       no-undo.
define variable ecdb_fr           like si_db        no-undo.
define variable ecnbr_to          like ecm_nbr      no-undo.
define variable ecid_to           like wo_lot       no-undo.
define variable ecdb_to           like si_db        no-undo.
define variable ectype_fr         like ecm_type     no-undo.
define variable ecdgrp_fr         like ecm_assign   no-undo.
define variable ecinit_fr         like ecm_init     no-undo.
define variable ecstatus_fr       like ecm_status   no-undo.
define variable ecuser1_fr        like ecm_user1    no-undo.
define variable ecuser2_fr        like ecm_user2    no-undo.
define variable ectype_to         like ecm_type     no-undo.
define variable ecdgrp_to         like ecm_assign   no-undo.
define variable ecinit_to         like ecm_init     no-undo.
define variable ecstatus_to       like ecm_status   no-undo.
define variable ecuser1_to        like ecm_user1    no-undo.
define variable ecuser2_to        like ecm_user2    no-undo.
define variable unsub             like mfc_logical  no-undo.
define variable submtd            like mfc_logical  no-undo.
define variable appr              like mfc_logical  no-undo.
define variable relsd             like mfc_logical  no-undo.
define variable incorp            like mfc_logical  no-undo.
define variable implem            like mfc_logical  no-undo.
define variable closed            like mfc_logical  no-undo.
define variable appro             like mfc_logical  no-undo.
define variable msgoly            like mfc_logical  no-undo.
define variable updecn            like mfc_logical  no-undo.
define variable first_cmmt        like mfc_logical  no-undo.
define variable pagecmt_fr          as integer      no-undo.
define variable pagetxt_fr          as integer      no-undo.
define variable pagecmt_to          as integer      no-undo.
define variable pagetxt_to          as integer      no-undo.
define variable ecmid             like wo_lot       no-undo.
define variable dbase             like si_db        no-undo.
define variable i                   as integer      no-undo.
define variable ii                  as integer      no-undo.
define variable ecmcmmt             as character    no-undo.
define variable cmmt              like mfc_logical  no-undo.
define variable rel               like mfc_logical  no-undo.
define variable ecn_ecr           like ecm_doc_type no-undo.
define variable unsub_d           like ecm_sub_date no-undo.
define variable submtd_d          like ecm_sub_date no-undo.
define variable relsd_d           like ecm_sub_date no-undo.
define variable appro_d           like ecm_sub_date no-undo.
define variable closed_d          like ecm_sub_date no-undo.
define variable skip1               as character    no-undo.
define variable closed_yn         like mfc_logical  no-undo.
define variable l_ecm_status        as character    no-undo.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
ecnbr_fr        colon 25
   ecnbr_to        colon 50    label {t001.i}
   ecid_fr         colon 25
   ecid_to         colon 50    label {t001.i}
   ecdb_fr         colon 25
   ecdb_to         colon 50    label {t001.i}
   ectype_fr       colon 25
   ectype_to       colon 50    label {t001.i}
   ecdgrp_fr       colon 25    label "Design Group"
   ecdgrp_to       colon 50    label {t001.i}
   ecinit_fr       colon 25    label "Created By"
   ecinit_to       colon 50    label {t001.i}
   ecstatus_fr     colon 25
   ecstatus_to     colon 50    label {t001.i}
   ecuser1_fr      colon 25    label "User Code 1"
   ecuser1_to      colon 50    label {t001.i}
   ecuser2_fr      colon 25    label "User Code 2"
   ecuser2_to      colon 50    label {t001.i}
   skip(1)
   unsub           colon 25    label "Pre-submission"
   pagecmt_fr      colon 50    label "Comment Page" format ">>9"
   pagecmt_to      colon 60    label {t001.i}       format ">>9"
   submtd          colon 25    label "Submitted"
   pagetxt_fr      colon 50    label "Text Order"  format ">>9"
   pagetxt_to      colon 60    label {t001.i}      format ">>9"
   appr            colon 25    label "Approved"
   appro           colon 50    label "Approvals"
   relsd           colon 25    label "Released"

   ecn_ecr         colon 50    label "PCO/PCR" format "x(3)"
   incorp          colon 25    label "Incorporated"

   implem          colon 25    label "Implemented"
   closed          colon 25    label "Closed"
with frame a width 80 side-labels NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   ecmcmmt           colon 27  format "x(76)"
with STREAM-IO /*GUI*/  frame cmmt02 down width 132 no-attr-space no-box no-label.

FORM /*GUI*/ 
   skip(2)
   ecmcmmt           colon 25  format "x(76)"  label "Comment"
with STREAM-IO /*GUI*/  frame cmmt01 down width 132 no-attr-space no-box side-labels.

/* SET EXTERNAL LABELS */
setFrameLabels(frame cmmt01:handle).

FORM /*GUI*/ 

   rsud_group        colon 27  column-label "Approval!Group"
   rsud_sequence     colon 45  column-label "Sequence"
   rsud_approved     colon 60  column-label "Approved"
   rsud_approverid   colon 75  column-label "Approved By"
   rsud_appr_date    colon 90  column-label "Approval!Date"
with STREAM-IO /*GUI*/  frame appr  down WIDTH 132 no-attr-space.

/* SET EXTERNAL LABELS */
setFrameLabels(frame appr:handle).

view frame a.
assign
   unsub      = no
   submtd     = yes
   appr       = yes
   relsd      = yes
   incorp     = no
   implem     = no
   closed     = no
   pagecmt_fr = 1
   pagecmt_to = 99
   pagetxt_fr = 1
   pagetxt_to = 99
   appro      = yes
   ecn_ecr    = "PCR".

{wbrp01.i}
repeat:
   if ecnbr_to    = hi_char then ecnbr_to    = "".
   if ecid_to     = hi_char then ecid_to     = "".
   if ecdb_to     = hi_char then ecdb_to     = "".
   if ectype_to   = hi_char then ectype_to   = "".
   if ecdgrp_to   = hi_char then ecdgrp_to   = "".
   if ecinit_to   = hi_char then ecinit_to   = "".
   if ecstatus_to = hi_char then ecstatus_to = "".
   if ecuser1_to  = hi_char then ecuser1_to  = "".
   if ecuser2_to  = hi_char then ecuser2_to  = "".

   if c-application-mode <> 'web'
   then
      update
         ecnbr_fr
         ecnbr_to
         ecid_fr
         ecid_to
         ecdb_fr
         ecdb_to
         ectype_fr
         ectype_to
         ecdgrp_fr
         ecdgrp_to
         ecinit_fr
         ecinit_to
         ecstatus_fr
         ecstatus_to
         ecuser1_fr
         ecuser1_to
         ecuser2_fr
         ecuser2_to
         unsub
         submtd
         appr
         relsd
         incorp
         implem
         closed
         pagecmt_fr
         pagecmt_to
         pagetxt_fr
         pagetxt_to
         appro
         ecn_ecr

      with frame a.

   {wbrp06.i &command = update &fields = "  ecnbr_fr ecnbr_to ecid_fr
      ecid_to ecdb_fr ecdb_to ectype_fr ectype_to ecdgrp_fr ecdgrp_to
      ecinit_fr ecinit_to ecstatus_fr ecstatus_to ecuser1_fr ecuser1_to
      ecuser2_fr ecuser2_to unsub submtd appr relsd incorp implem closed
      pagecmt_fr pagecmt_to pagetxt_fr pagetxt_to appro ecn_ecr " &frm = "a"}

   if (c-application-mode <> 'web')
    or (c-application-mode = 'web'
   and (c-web-request begins 'data'))
   then do:

      bcdparm = "".

      {gprun.i ""gpquote1.p"" "(input-output bcdparm,31,
           ecnbr_fr, ecnbr_to, ecid_fr, ecid_to, ecdb_fr, ecdb_to,
           ectype_fr, ectype_to, ecdgrp_fr, ecdgrp_to, ecinit_fr,
           ecinit_to, ecstatus_fr, ecstatus_to, ecuser1_fr, ecuser1_to,
           ecuser2_fr, ecuser2_to, string(unsub), string(submtd),
           string(appr), string(relsd), string(incorp), string(implem),
           string(closed), string(pagecmt_fr), string(pagecmt_to),
           string(pagetxt_fr), string(pagetxt_to), string(appro),
           string(ecn_ecr), null_char,
           null_char, null_char, null_char, null_char,
           null_char, null_char, null_char, null_char)"}

      if ecnbr_to    = ""
      then
         ecnbr_to    = hi_char.
      if ecid_to     = ""
      then
         ecid_to     = hi_char.
      if ecdb_to     = ""
      then
         ecdb_to     = hi_char.
      if ectype_to   = ""
      then
         ectype_to   = hi_char.
      if ecdgrp_to   = ""
      then
         ecdgrp_to   = hi_char.
      if ecinit_to   = ""
      then
         ecinit_to   = hi_char.
      if ecstatus_to = ""
      then
         ecstatus_to = hi_char.
      if ecuser1_to  = ""
      then
         ecuser1_to  = hi_char.
      if ecuser2_to  = ""
      then
         ecuser2_to  = hi_char.

   end.

   /* ASSIGNED EXACT FIELD LENGTH TO INPUT VARIABLES        */
   /* FOR PROPER RECORD SELECTION AS PER SELECTION CRITERIA */

   assign
      ecnbr_to = string(ecnbr_to,"x(8)")
      ecid_to  = string(ecid_to,"x(8)")
      ecdb_to  = string(ecdb_to,"x(8)")
      ecnbr_fr = string(ecnbr_fr,"x(8)")
      ecid_fr  = string(ecid_fr,"x(8)")
      ecdb_fr  = string(ecdb_fr,"x(8)").

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "printer"
               &printWidth = 132
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "yes"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

   {mfphead.i}

   FORM /*GUI*/  header
      skip(1)
   with STREAM-IO /*GUI*/  frame a1 width 132 page-top.
   view frame a1.

   for each ecm_mstr
      where (substring(ecm_nbr,1,8)  >= ecnbr_fr
        and substring(ecm_nbr,1,8)   <= ecnbr_to)
        and (substring(ecm_nbr,9,8)  >= ecid_fr
        and substring(ecm_nbr,9,8)   <= ecid_to)
        and (substring(ecm_nbr,17,8) >= ecdb_fr
        and substring(ecm_nbr,17,8)  <= ecdb_to)
        and (ecm_type                >= ectype_fr
        and ecm_type                 <= ectype_to)
        and (ecm_assign              >= ecdgrp_fr
        and ecm_assign               <= ecdgrp_to)
        and (ecm_init                >= ecinit_fr
        and ecm_init                 <= ecinit_to)
        and (ecm_user1               >= ecuser1_fr
        and ecm_user1                <= ecuser1_to)
        and (ecm_user2               >= ecuser2_fr
        and ecm_user2                <= ecuser2_to)
        and ecm_doc_type              = ecn_ecr

      no-lock
      with frame form01 down:

      /* BEGIN OF ADDED SECTION */

      run get_ecm_status (buffer ecm_mstr, output l_ecm_status).

      if not ((unsub
      and  l_ecm_status = "UNSUBMITTED")
       or (submtd
      and (l_ecm_status = "SUBMITTED"
       or  l_ecm_status = "REROUTED" ))
       or (appr
      and  l_ecm_status = "APPROVED")
       or (relsd
      and  l_ecm_status = "RELEASED")
       or (incorp
      and  l_ecm_status = "INCORPORATED")
       or (implem
      and  l_ecm_status = "IMPLEMENT")
       or (closed
      and  l_ecm_status = "CLOSED"))
      then
         next.

      if ecm_nbr = "*000000*" or substring(ecm_nbr,25,1) = "*"
      then
         next.

      ecmid = substring(ecm_nbr,9,8).
      dbase = substring(ecm_nbr,17,8).

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame form01:handle).
      display
         {ecform01.i}
      with frame form01 attr-space side-labels width 132 STREAM-IO /*GUI*/ .

      if ecm_close_date <> ?
      then
         closed_yn = yes.
      else closed_yn = no.
      do with frame form07:
         /* SET EXTERNAL LABELS */
         setFrameLabels(frame form07:handle).
         display
            {ecform07.i}
         with frame form07 attr-space side-labels width 132 STREAM-IO /*GUI*/ .
      end. /* do with */
      if ecm_cmtindx <> 0
      then do:

         first_cmmt = yes.
         for each cmt_det
            where cmt_indx = ecm_cmtindx
            no-lock:

            if cmt_seq + 1  < pagecmt_fr
            or cmt_seq + 1 > pagecmt_to
            then
               next.

            repeat i = 1 to 15:
               if first_cmmt
               then do:

                  display
                     cmt_cmmt[i] @ ecmcmmt
                  with frame cmmt01 STREAM-IO /*GUI*/ .

                  first_cmmt = no.
               end.
               else do:
                  if cmt_cmmt[i] <> ""
                  then do:

                     display
                        cmt_cmmt[i] @ ecmcmmt
                     with frame cmmt02 STREAM-IO /*GUI*/ .
                     down 1 with frame cmmt02.
                  end.
               end.
            end.
            display
               skip(1)
            with frame xxx STREAM-IO /*GUI*/ .
         end.
      end.

      if appro
      and can-find (first rsu_mstr where rsu_doc_nbr = ecm_nbr)
      then do:

         for each rsu_mstr
            where rsu_doc_nbr = ecm_nbr
            no-lock,
            each rsud_det where rsud_index = rsu_index
            no-lock
            by rsud_sequence:

            display
               rsud_group
               rsud_sequence
               rsud_approverid
               rsud_appr_date
               rsud_approved
            with frame appr STREAM-IO /*GUI*/ .
            down 1 with frame appr.
         end.
         display
            skip(1)
         with frame x STREAM-IO /*GUI*/ .
      end.

      ecmnbr = ecm_nbr.

      {gprun.i ""ececrp01.p""}

      /* INPUT PARAMETER ecn_ecr ADDED */
      {gprun.i ""ececrp03.p""
         "(input ecn_ecr)"}

      {gprun.i ""ececrp04.p""}    /* ROUTING FILE */
      {gprun.i ""ececrp05.p""}    /* ITEM SPECIFICATION */

      for each ecd3_det
         where ecd3_nbr   = ecm_nbr
         and (ecd3_order >= pagetxt_fr
         and ecd3_order  <= pagetxt_to)
         no-lock
         by ecd3_order:

         if ecd3_cmtindx <> 0
         then do:

            page.

            display
               getTermLabel("PRODUCT_CHANGE_DOCUMENT_(ORDER_NO",45) + " " +
               string(ecd3_order) + ")" @ ecmcmmt with frame cmmt02 STREAM-IO /*GUI*/ .
            down 1 with frame cmmt02.
            display "-----------------------------------------"
               @ ecmcmmt with frame cmmt02 STREAM-IO /*GUI*/ .
            down 2 with frame cmmt02.
            for each cmt_det
               where cmt_indx = ecd3_cmtindx
               no-lock:
               repeat i = 1 to 15:
                  display
                     cmt_cmmt[i] @ ecmcmmt
                  with frame cmmt02 STREAM-IO /*GUI*/ .
                  down 1 with frame cmmt02.
               end.
               display skip(1) WITH STREAM-IO /*GUI*/ .
            end.
         end.
      end.
      page.
      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   end.

   /* REPORT TRAILER */
   {mfrtrail.i}
end.

{wbrp04.i &frame-spec = a}

/* INCLUDE FILE TO GET THE STATUS OF THE PCR/PCO */
{ecstatus.i}
